package com.tongtech.example.mapper;

import com.tongtech.example.dto.UserDTO;
import com.tongtech.example.entity.User;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper(uses = StringToDateConverter.class)
public interface UserMapper {
    UserMapper INSTANCE = Mappers.getMapper(UserMapper.class);
    
    @Mapping(source = "birthDate", target = "birthDate", qualifiedBy = StringToDateConverter.StringToDate.class)
    User toEntity(UserDTO dto);
    
    @Mapping(source = "birthDate", target = "birthDate", qualifiedBy = StringToDateConverter.DateToString.class)
    UserDTO toDto(User entity);
}
